import { createSlice } from "@reduxjs/toolkit";
import type { PayloadAction } from "@reduxjs/toolkit";
import type { UserStoreType, UserInfoType } from "@/typings/storeType";

const userSlice = createSlice({
  name: "user",
  initialState: (): UserStoreType => {
    return {
      userInfo: null
    };
  },
  reducers: {
    setUserInfo: (state, action: PayloadAction<UserInfoType>) => {
      console.log("修改用户信息: ", action);
      state.userInfo = action.payload;
    }
  }
});

export const { setUserInfo } = userSlice.actions;

export { userSlice };
